﻿USE [ASPNETVN.PORTAL]
GO
/****** Object:  StoredProcedure [dbo].[p_FE_Attachment_Delete]    Script Date: 06/19/2008 15:40:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Attachment_Delete]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Attachment_Delete]
	@ID int
AS

DELETE FROM 
	[dbo].[t_FE_Attachments]
WHERE
	[ID] = @ID


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Attachment_DeleteBy_PackageID]    Script Date: 06/19/2008 15:40:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Attachment_DeleteBy_PackageID]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Attachment_DeleteBy_PackageID]
	@PackageID int
AS

DELETE FROM [dbo].[t_FE_Attachments]
WHERE
	[PackageID] = @PackageID


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Attachment_DeleteDynamic]    Script Date: 06/19/2008 15:40:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Attachment_DeleteDynamic]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Attachment_DeleteDynamic]
	@WhereCondition nvarchar(500)
AS

DECLARE @SQL nvarchar(3250)

SET @SQL = 'DELETE FROM [dbo].[t_FE_Attachments] WHERE ' + @WhereCondition

EXEC sp_executesql @SQL


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Attachment_Insert]    Script Date: 06/19/2008 15:40:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO



------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Attachment_Insert]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Attachment_Insert]
	@PackageID int,
	@OriginalFileName nvarchar(256),
	@FileName nvarchar(256),
	@FileSize bigint,
	@FileType varchar(8),
	@TotalDownloads int,
	@Url nvarchar(512),
	@ID int OUTPUT
AS
INSERT INTO [dbo].[t_FE_Attachments]
(
	[PackageID],
	[OriginalFileName],
	[FileName],
	[FileSize],
	[FileType],
	[TotalDownloads],
	[Url]
)
VALUES 
(
	@PackageID,
	@OriginalFileName,
	@FileName,
	@FileSize,
	@FileType,
	@TotalDownloads,
	@Url
)

SET @ID = SCOPE_IDENTITY()


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Attachment_InsertUpdate]    Script Date: 06/19/2008 15:40:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Attachment_InsertUpdate]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Attachment_InsertUpdate]
	@ID int,
	@PackageID int,
	@OriginalFileName nvarchar(256),
	@FileName nvarchar(256),
	@FileSize bigint,
	@FileType varchar(8),
	@TotalDownloads int,
	@Url nvarchar(512)
AS
IF EXISTS(SELECT [ID] FROM [dbo].[t_FE_Attachments] WHERE [ID] = @ID)
	BEGIN
		UPDATE
			[dbo].[t_FE_Attachments] 
		SET
			[PackageID] = @PackageID,
			[OriginalFileName] = @OriginalFileName,
			[FileName] = @FileName,
			[FileSize] = @FileSize,
			[FileType] = @FileType,
			[TotalDownloads] = @TotalDownloads,
			[Url] = @Url
		WHERE
			[ID] = @ID
	END
ELSE
	BEGIN
		
		INSERT INTO [dbo].[t_FE_Attachments]
		(
			[PackageID],
			[OriginalFileName],
			[FileName],
			[FileSize],
			[FileType],
			[TotalDownloads],
			[Url]
		)
		VALUES 
		(
			@PackageID,
			@OriginalFileName,
			@FileName,
			@FileSize,
			@FileType,
			@TotalDownloads,
			@Url
		)		
	END

GO
/****** Object:  StoredProcedure [dbo].[p_FE_Attachment_Load]    Script Date: 06/19/2008 15:40:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Attachment_Load]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Attachment_Load]
	@ID int
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

SELECT
	[ID],
	[PackageID],
	[OriginalFileName],
	[FileName],
	[FileSize],
	[FileType],
	[TotalDownloads],
	[Url]
FROM
	[dbo].[t_FE_Attachments]
WHERE
	[ID] = @ID

GO
/****** Object:  StoredProcedure [dbo].[p_FE_Attachment_SelectAll]    Script Date: 06/19/2008 15:40:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Attachment_SelectAll]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Attachment_SelectAll]
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

SELECT
	[ID],
	[PackageID],
	[OriginalFileName],
	[FileName],
	[FileSize],
	[FileType],
	[TotalDownloads],
	[Url]
FROM
	[dbo].[t_FE_Attachments]	


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Attachment_SelectBy_PackageID]    Script Date: 06/19/2008 15:40:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Attachment_SelectBy_PackageID]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Attachment_SelectBy_PackageID]
	@PackageID int
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

SELECT
	[ID],
	[PackageID],
	[OriginalFileName],
	[FileName],
	[FileSize],
	[FileType],
	[TotalDownloads],
	[Url]
FROM
	[dbo].[t_FE_Attachments]
WHERE
	[PackageID] = @PackageID


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Attachment_SelectDynamic]    Script Date: 06/19/2008 15:40:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Attachment_SelectDynamic]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Attachment_SelectDynamic]
	@WhereCondition nvarchar(500),
	@OrderByExpression nvarchar(250) = NULL
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

DECLARE @SQL nvarchar(3250)

SET @SQL = 
'SELECT 
	[ID],
	[PackageID],
	[OriginalFileName],
	[FileName],
	[FileSize],
	[FileType],
	[TotalDownloads],
	[Url]
FROM [dbo].[t_FE_Attachments] 
WHERE ' + @WhereCondition

IF @OrderByExpression IS NOT NULL AND LEN(@OrderByExpression) > 0
BEGIN
	SET @SQL = @SQL + ' ORDER BY ' + @OrderByExpression
END

EXEC sp_executesql @SQL


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Attachment_Update]    Script Date: 06/19/2008 15:40:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Attachment_Update]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Attachment_Update]
	@ID int,
	@PackageID int,
	@OriginalFileName nvarchar(256),
	@FileName nvarchar(256),
	@FileSize bigint,
	@FileType varchar(8),
	@TotalDownloads int,
	@Url nvarchar(512)
AS

UPDATE
	[dbo].[t_FE_Attachments]
SET
	[PackageID] = @PackageID,
	[OriginalFileName] = @OriginalFileName,
	[FileName] = @FileName,
	[FileSize] = @FileSize,
	[FileType] = @FileType,
	[TotalDownloads] = @TotalDownloads,
	[Url] = @Url
WHERE
	[ID] = @ID


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Category_Delete]    Script Date: 06/19/2008 15:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Category_Delete]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Category_Delete]
	@ID int
AS

DELETE FROM 
	[dbo].[t_FE_Categories]
WHERE
	[ID] = @ID


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Category_DeleteDynamic]    Script Date: 06/19/2008 15:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Category_DeleteDynamic]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Category_DeleteDynamic]
	@WhereCondition nvarchar(500)
AS

DECLARE @SQL nvarchar(3250)

SET @SQL = 'DELETE FROM [dbo].[t_FE_Categories] WHERE ' + @WhereCondition

EXEC sp_executesql @SQL


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Category_Insert]    Script Date: 06/19/2008 15:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO



------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Category_Insert]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Category_Insert]
	@ModuleID int,
	@ParentID int,
	@Name nvarchar(128),
	@ID int OUTPUT
AS
INSERT INTO [dbo].[t_FE_Categories]
(
	[ModuleID],
	[ParentID],
	[Name]
)
VALUES 
(
	@ModuleID,
	@ParentID,
	@Name
)

SET @ID = SCOPE_IDENTITY()


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Category_InsertUpdate]    Script Date: 06/19/2008 15:40:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Category_InsertUpdate]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Category_InsertUpdate]
	@ID int,
	@ModuleID int,
	@ParentID int,
	@Name nvarchar(128)
AS
IF EXISTS(SELECT [ID] FROM [dbo].[t_FE_Categories] WHERE [ID] = @ID)
	BEGIN
		UPDATE
			[dbo].[t_FE_Categories] 
		SET
			[ModuleID] = @ModuleID,
			[ParentID] = @ParentID,
			[Name] = @Name
		WHERE
			[ID] = @ID
	END
ELSE
	BEGIN
		
		INSERT INTO [dbo].[t_FE_Categories]
		(
			[ModuleID],
			[ParentID],
			[Name]
		)
		VALUES 
		(
			@ModuleID,
			@ParentID,
			@Name
		)		
	END

GO
/****** Object:  StoredProcedure [dbo].[p_FE_Category_Load]    Script Date: 06/19/2008 15:40:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Category_Load]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Category_Load]
	@ID int
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

SELECT
	[ID],
	[ModuleID],
	[ParentID],
	[Name]
FROM
	[dbo].[t_FE_Categories]
WHERE
	[ID] = @ID

GO
/****** Object:  StoredProcedure [dbo].[p_FE_Category_SelectAll]    Script Date: 06/19/2008 15:40:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Category_SelectAll]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Category_SelectAll]
	@ModuleID int
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

SELECT
	[ID],
	[ModuleID],
	[ParentID],
	[Name]
FROM
	[dbo].[t_FE_Categories]	
WHERE 
	(ModuleID = @ModuleID)


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Category_SelectDynamic]    Script Date: 06/19/2008 15:40:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Category_SelectDynamic]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Category_SelectDynamic]
	@WhereCondition nvarchar(500),
	@OrderByExpression nvarchar(250) = NULL
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

DECLARE @SQL nvarchar(3250)

SET @SQL = 
'SELECT 
	[ID],
	[ModuleID],
	[ParentID],
	[Name]
FROM [dbo].[t_FE_Categories] 
WHERE ' + @WhereCondition

IF @OrderByExpression IS NOT NULL AND LEN(@OrderByExpression) > 0
BEGIN
	SET @SQL = @SQL + ' ORDER BY ' + @OrderByExpression
END

EXEC sp_executesql @SQL


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Category_Update]    Script Date: 06/19/2008 15:40:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Category_Update]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Category_Update]
	@ID int,
	@ModuleID int,
	@ParentID int,
	@Name nvarchar(128)
AS

UPDATE
	[dbo].[t_FE_Categories]
SET
	[ModuleID] = @ModuleID,
	[ParentID] = @ParentID,
	[Name] = @Name
WHERE
	[ID] = @ID


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Comment_Delete]    Script Date: 06/19/2008 15:40:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Comment_Delete]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Comment_Delete]
	@ID int
AS

DELETE FROM 
	[dbo].[t_FE_Comments]
WHERE
	[ID] = @ID


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Comment_DeleteBy_PackageID]    Script Date: 06/19/2008 15:40:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Comment_DeleteBy_PackageID]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Comment_DeleteBy_PackageID]
	@PackageID int
AS

DELETE FROM [dbo].[t_FE_Comments]
WHERE
	[PackageID] = @PackageID


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Comment_DeleteDynamic]    Script Date: 06/19/2008 15:40:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Comment_DeleteDynamic]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Comment_DeleteDynamic]
	@WhereCondition nvarchar(500)
AS

DECLARE @SQL nvarchar(3250)

SET @SQL = 'DELETE FROM [dbo].[t_FE_Comments] WHERE ' + @WhereCondition

EXEC sp_executesql @SQL


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Comment_Insert]    Script Date: 06/19/2008 15:40:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO



------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Comment_Insert]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Comment_Insert]
	@PackageID int,
	@Content ntext,
	@CreatedBy nvarchar(128),
	@CreationTime datetime,
	@ID int OUTPUT
AS
INSERT INTO [dbo].[t_FE_Comments]
(
	[PackageID],
	[Content],
	[CreatedBy],
	[CreationTime]
)
VALUES 
(
	@PackageID,
	@Content,
	@CreatedBy,
	@CreationTime
)

SET @ID = SCOPE_IDENTITY()


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Comment_InsertUpdate]    Script Date: 06/19/2008 15:40:36 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Comment_InsertUpdate]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Comment_InsertUpdate]
	@ID int,
	@PackageID int,
	@Content ntext,
	@CreatedBy nvarchar(128),
	@CreationTime datetime
AS
IF EXISTS(SELECT [ID] FROM [dbo].[t_FE_Comments] WHERE [ID] = @ID)
	BEGIN
		UPDATE
			[dbo].[t_FE_Comments] 
		SET
			[PackageID] = @PackageID,
			[Content] = @Content,
			[CreatedBy] = @CreatedBy,
			[CreationTime] = @CreationTime
		WHERE
			[ID] = @ID
	END
ELSE
	BEGIN
		
		INSERT INTO [dbo].[t_FE_Comments]
		(
			[PackageID],
			[Content],
			[CreatedBy],
			[CreationTime]
		)
		VALUES 
		(
			@PackageID,
			@Content,
			@CreatedBy,
			@CreationTime
		)		
	END

GO
/****** Object:  StoredProcedure [dbo].[p_FE_Comment_Load]    Script Date: 06/19/2008 15:40:37 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Comment_Load]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Comment_Load]
	@ID int
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

SELECT
	[ID],
	[PackageID],
	[Content],
	[CreatedBy],
	[CreationTime]
FROM
	[dbo].[t_FE_Comments]
WHERE
	[ID] = @ID

GO
/****** Object:  StoredProcedure [dbo].[p_FE_Comment_SelectAll]    Script Date: 06/19/2008 15:40:37 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Comment_SelectAll]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Comment_SelectAll]
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

SELECT
	[ID],
	[PackageID],
	[Content],
	[CreatedBy],
	[CreationTime]
FROM
	[dbo].[t_FE_Comments]	


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Comment_SelectBy_PackageID]    Script Date: 06/19/2008 15:40:37 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Comment_SelectBy_PackageID]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Comment_SelectBy_PackageID]
	@PackageID int
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

SELECT
	[ID],
	[PackageID],
	[Content],
	[CreatedBy],
	[CreationTime]
FROM
	[dbo].[t_FE_Comments]
WHERE
	[PackageID] = @PackageID


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Comment_SelectDynamic]    Script Date: 06/19/2008 15:40:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Comment_SelectDynamic]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Comment_SelectDynamic]
	@WhereCondition nvarchar(500),
	@OrderByExpression nvarchar(250) = NULL
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

DECLARE @SQL nvarchar(3250)

SET @SQL = 
'SELECT 
	[ID],
	[PackageID],
	[Content],
	[CreatedBy],
	[CreationTime]
FROM [dbo].[t_FE_Comments] 
WHERE ' + @WhereCondition

IF @OrderByExpression IS NOT NULL AND LEN(@OrderByExpression) > 0
BEGIN
	SET @SQL = @SQL + ' ORDER BY ' + @OrderByExpression
END

EXEC sp_executesql @SQL


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Comment_Update]    Script Date: 06/19/2008 15:40:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Comment_Update]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Comment_Update]
	@ID int,
	@PackageID int,
	@Content ntext,
	@CreatedBy nvarchar(128),
	@CreationTime datetime
AS

UPDATE
	[dbo].[t_FE_Comments]
SET
	[PackageID] = @PackageID,
	[Content] = @Content,
	[CreatedBy] = @CreatedBy,
	[CreationTime] = @CreationTime
WHERE
	[ID] = @ID


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Package_Delete]    Script Date: 06/19/2008 15:40:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Package_Delete]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Package_Delete]
	@ID int
AS
DELETE FROM 
	[dbo].[t_FE_Packages]
WHERE
	[ID] = @ID


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Package_DeleteBy_CategoryID]    Script Date: 06/19/2008 15:40:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Package_DeleteBy_CategoryID]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Package_DeleteBy_CategoryID]
	@CategoryID int
AS

SET NOCOUNT ON

DELETE FROM [dbo].[t_FE_Packages]
WHERE
	[CategoryID] = @CategoryID


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Package_DeleteDynamic]    Script Date: 06/19/2008 15:40:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Package_DeleteDynamic]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Package_DeleteDynamic]
	@WhereCondition nvarchar(500)
AS

SET NOCOUNT ON

DECLARE @SQL nvarchar(3250)

SET @SQL = 'DELETE FROM [dbo].[t_FE_Packages] WHERE ' + @WhereCondition

EXEC sp_executesql @SQL


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Package_Insert]    Script Date: 06/19/2008 15:40:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO



------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Package_Insert]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Package_Insert]
	@CategoryID int,
	@Title nvarchar(512),
	@Description ntext,
	@CreatedBy nvarchar(128),
	@CreationTime datetime,
	@IsPublic bit,
	@ID int OUTPUT
AS
INSERT INTO [dbo].[t_FE_Packages]
(
	[CategoryID],
	[Title],
	[Description],
	[CreatedBy],
	[CreationTime],
	[IsPublic]
)
VALUES 
(
	@CategoryID,
	@Title,
	@Description,
	@CreatedBy,
	@CreationTime,
	@IsPublic
)

SET @ID = SCOPE_IDENTITY()


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Package_InsertUpdate]    Script Date: 06/19/2008 15:40:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Package_InsertUpdate]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Package_InsertUpdate]
	@ID int,
	@CategoryID int,
	@Title nvarchar(512),
	@Description ntext,
	@CreatedBy nvarchar(128),
	@CreationTime datetime,
	@IsPublic bit
AS
IF EXISTS(SELECT [ID] FROM [dbo].[t_FE_Packages] WHERE [ID] = @ID)
	BEGIN
		UPDATE
			[dbo].[t_FE_Packages] 
		SET
			[CategoryID] = @CategoryID,
			[Title] = @Title,
			[Description] = @Description,
			[CreatedBy] = @CreatedBy,
			[CreationTime] = @CreationTime,
			[IsPublic] = @IsPublic
		WHERE
			[ID] = @ID
	END
ELSE
	BEGIN
		
		INSERT INTO [dbo].[t_FE_Packages]
		(
			[CategoryID],
			[Title],
			[Description],
			[CreatedBy],
			[CreationTime],
			[IsPublic]
		)
		VALUES 
		(
			@CategoryID,
			@Title,
			@Description,
			@CreatedBy,
			@CreationTime,
			@IsPublic
		)		
	END

GO
/****** Object:  StoredProcedure [dbo].[p_FE_Package_Load]    Script Date: 06/19/2008 15:40:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Package_Load]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Package_Load]
	@ID int
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

SELECT
	[ID],
	[CategoryID],
	[Title],
	[Description],
	[CreatedBy],
	[CreationTime],
	[IsPublic]
FROM
	[dbo].[t_FE_Packages]
WHERE
	[ID] = @ID


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Package_SelectAll]    Script Date: 06/19/2008 15:40:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Package_SelectAll]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Package_SelectAll]
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

SELECT
	[ID],
	[CategoryID],
	[Title],
	[Description],
	[CreatedBy],
	[CreationTime],
	[IsPublic]
FROM
	[dbo].[t_FE_Packages]


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Package_SelectBy_CategoryID]    Script Date: 06/19/2008 15:40:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Package_SelectBy_CategoryID]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Package_SelectBy_CategoryID]
	@CategoryID int
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
IF (@CategoryID > 0)
	BEGIN
		SELECT
			[ID],
			[CategoryID],
			[Title],
			[Description],
			[CreatedBy],
			[CreationTime],
			[IsPublic]
		FROM
			[dbo].[t_FE_Packages]
		WHERE
			[CategoryID] = @CategoryID	
		ORDER BY
			[CategoryID] DESC
	END
ELSE
	BEGIN
		SELECT
			[ID],
			[CategoryID],
			[Title],
			[Description],
			[CreatedBy],
			[CreationTime],
			[IsPublic]
		FROM
			[dbo].[t_FE_Packages]	
		ORDER BY
			[CategoryID] DESC
				
	END
GO
/****** Object:  StoredProcedure [dbo].[p_FE_Package_SelectDynamic]    Script Date: 06/19/2008 15:40:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Package_SelectDynamic]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Package_SelectDynamic]
	@WhereCondition nvarchar(500),
	@OrderByExpression nvarchar(250) = NULL
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

DECLARE @SQL nvarchar(3250)

SET @SQL = 'SELECT 	[ID],
	[CategoryID],
	[Title],
	[Description],
	[CreatedBy],
	[CreationTime],
	[IsPublic]
 FROM [dbo].[t_FE_Packages] WHERE ' + @WhereCondition

IF @OrderByExpression IS NOT NULL AND LEN(@OrderByExpression) > 0
BEGIN
	SET @SQL = @SQL + ' ORDER BY ' + @OrderByExpression
END

EXEC sp_executesql @SQL


GO
/****** Object:  StoredProcedure [dbo].[p_FE_Package_Update]    Script Date: 06/19/2008 15:40:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_Package_Update]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_Package_Update]
	@ID int,
	@CategoryID int,
	@Title nvarchar(512),
	@Description ntext,
	@CreatedBy nvarchar(128),
	@CreationTime datetime,
	@IsPublic bit
AS
UPDATE
	[dbo].[t_FE_Packages]
SET
	[CategoryID] = @CategoryID,
	[Title] = @Title,
	[Description] = @Description,
	[CreatedBy] = @CreatedBy,
	[CreationTime] = @CreationTime,
	[IsPublic] = @IsPublic
WHERE
	[ID] = @ID


GO
/****** Object:  StoredProcedure [dbo].[p_FE_PackageDetail_Delete]    Script Date: 06/19/2008 15:40:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_PackageDetail_Delete]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_PackageDetail_Delete]
	@ID int
AS
DELETE FROM 
	[dbo].[t_FE_PackageDetails]
WHERE
	[ID] = @ID


GO
/****** Object:  StoredProcedure [dbo].[p_FE_PackageDetail_DeleteBy_PackageID]    Script Date: 06/19/2008 15:40:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_PackageDetail_DeleteBy_PackageID]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_PackageDetail_DeleteBy_PackageID]
	@PackageID int
AS

SET NOCOUNT ON

DELETE FROM [dbo].[t_FE_PackageDetails]
WHERE
	[PackageID] = @PackageID


GO
/****** Object:  StoredProcedure [dbo].[p_FE_PackageDetail_DeleteBy_UserID]    Script Date: 06/19/2008 15:40:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_PackageDetail_DeleteBy_UserID]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_PackageDetail_DeleteBy_UserID]
	@UserID int
AS

SET NOCOUNT ON

DELETE FROM [dbo].[t_FE_PackageDetails]
WHERE
	[UserID] = @UserID


GO
/****** Object:  StoredProcedure [dbo].[p_FE_PackageDetail_DeleteDynamic]    Script Date: 06/19/2008 15:40:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_PackageDetail_DeleteDynamic]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_PackageDetail_DeleteDynamic]
	@WhereCondition nvarchar(500)
AS

SET NOCOUNT ON

DECLARE @SQL nvarchar(3250)

SET @SQL = 'DELETE FROM [dbo].[t_FE_PackageDetails] WHERE ' + @WhereCondition

EXEC sp_executesql @SQL


GO
/****** Object:  StoredProcedure [dbo].[p_FE_PackageDetail_Insert]    Script Date: 06/19/2008 15:40:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO



------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_PackageDetail_Insert]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_PackageDetail_Insert]
	@PackageID int,
	@UserID int,
	@ID int OUTPUT
AS
INSERT INTO [dbo].[t_FE_PackageDetails]
(
	[PackageID],
	[UserID]
)
VALUES 
(
	@PackageID,
	@UserID
)

SET @ID = SCOPE_IDENTITY()


GO
/****** Object:  StoredProcedure [dbo].[p_FE_PackageDetail_InsertUpdate]    Script Date: 06/19/2008 15:40:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_PackageDetail_InsertUpdate]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_PackageDetail_InsertUpdate]
	@ID int,
	@PackageID int,
	@UserID int
AS
IF EXISTS(SELECT [ID] FROM [dbo].[t_FE_PackageDetails] WHERE [ID] = @ID)
	BEGIN
		UPDATE
			[dbo].[t_FE_PackageDetails] 
		SET
			[PackageID] = @PackageID,
			[UserID] = @UserID
		WHERE
			[ID] = @ID
	END
ELSE
	BEGIN
		
		INSERT INTO [dbo].[t_FE_PackageDetails]
		(
			[PackageID],
			[UserID]
		)
		VALUES 
		(
			@PackageID,
			@UserID
		)		
	END

GO
/****** Object:  StoredProcedure [dbo].[p_FE_PackageDetail_Load]    Script Date: 06/19/2008 15:40:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_PackageDetail_Load]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_PackageDetail_Load]
	@ID int
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

SELECT
	[ID],
	[PackageID],
	[UserID]
FROM
	[dbo].[t_FE_PackageDetails]
WHERE
	[ID] = @ID


GO
/****** Object:  StoredProcedure [dbo].[p_FE_PackageDetail_SelectAll]    Script Date: 06/19/2008 15:40:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_PackageDetail_SelectAll]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_PackageDetail_SelectAll]
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

SELECT
	[ID],
	[PackageID],
	[UserID]
FROM
	[dbo].[t_FE_PackageDetails]


GO
/****** Object:  StoredProcedure [dbo].[p_FE_PackageDetail_SelectBy_PackageID]    Script Date: 06/19/2008 15:40:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_PackageDetail_SelectBy_PackageID]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_PackageDetail_SelectBy_PackageID]
	@PackageID int
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

SELECT
	[ID],
	[PackageID],
	[UserID]
FROM
	[dbo].[t_FE_PackageDetails]
WHERE
	[PackageID] = @PackageID


GO
/****** Object:  StoredProcedure [dbo].[p_FE_PackageDetail_SelectBy_UserID]    Script Date: 06/19/2008 15:40:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_PackageDetail_SelectBy_UserID]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_PackageDetail_SelectBy_UserID]
	@UserID int
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

SELECT
	[ID],
	[PackageID],
	[UserID]
FROM
	[dbo].[t_FE_PackageDetails]
WHERE
	[UserID] = @UserID


GO
/****** Object:  StoredProcedure [dbo].[p_FE_PackageDetail_SelectDynamic]    Script Date: 06/19/2008 15:40:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_PackageDetail_SelectDynamic]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_PackageDetail_SelectDynamic]
	@WhereCondition nvarchar(500),
	@OrderByExpression nvarchar(250) = NULL
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

DECLARE @SQL nvarchar(3250)

SET @SQL = 'SELECT 	[ID],
	[PackageID],
	[UserID]
 FROM [dbo].[t_FE_PackageDetails] WHERE ' + @WhereCondition

IF @OrderByExpression IS NOT NULL AND LEN(@OrderByExpression) > 0
BEGIN
	SET @SQL = @SQL + ' ORDER BY ' + @OrderByExpression
END

EXEC sp_executesql @SQL


GO
/****** Object:  StoredProcedure [dbo].[p_FE_PackageDetail_Update]    Script Date: 06/19/2008 15:40:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


------------------------------------------------------------------------------------------------------------------------
-- Stored procedure name: [dbo].[p_FE_PackageDetail_Update]
-- Database: ASPNETVN.PORTAL
-- Author: Ngo Thanh Tung
-- Time created: Monday, May 19, 2008
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [dbo].[p_FE_PackageDetail_Update]
	@ID int,
	@PackageID int,
	@UserID int
AS
UPDATE
	[dbo].[t_FE_PackageDetails]
SET
	[PackageID] = @PackageID,
	[UserID] = @UserID
WHERE
	[ID] = @ID

